from django.db import models
from home.models import User

# Create your models here.
class Note(models.Model):
    """笔记表"""
    titles = models.CharField(max_length=30, verbose_name='标题')
    content = models.TextField(verbose_name='内容')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    modify_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
    # 一对多, 外键
    user = models.ForeignKey(User, models.PROTECT)
    
    def __str__(self) -> str:
        return f"标题: {self.titles}, 内容: {self.content}, 创建时间: {self.create_time}, 修改时间: {self.modify_time}"
    
    class Meta:
        db_table = 'note'
        # managed = True
        verbose_name = '笔记表(note)'
        verbose_name_plural = '笔记表(note)'